package org.javabasics.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URLDecoder;

/**
 * Created by LUOLIANG on 2016/9/21.
 * 字节输入流
 */
public class FileInputStreamTest {

    public static void main(String[] args) throws IOException {
        String name = URLDecoder.decode(
                System.getProperty("user.dir") + "/basicsPractice/src/org/javabasics/io/FileInputStreamTest.java");
        FileInputStream fis = new FileInputStream(name);
        try {
            byte[] bbuf = new byte[1024];
            int hasRead = 0;
            while ((hasRead = fis.read(bbuf)) > 0) {
                System.out.println(new String(bbuf, 0, hasRead));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            fis.close();
        }
    }
}
